package com.qq.filter;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class MyListener implements ServletContextListener {
//应用程序的启动
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        System.out.println("程序启动了");
        //查询服务器信息
        String in = servletContextEvent.getServletContext().getServerInfo();
        System.out.println("服务器信息等于===》"+in);//结果为：服务器信息等于===》Apache Tomcat/8.5.34
        servletContextEvent.getServletContext().setAttribute("common","我是公用的信息");
        new MyThread().start();
        System.out.println("kjijiiij");
        return;
    }
//应用程序销毁
    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        System.out.println("销毁了！！！");
    }
}
